<?php

namespace App\Admin\Controllers;

use App\Distribute;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Form;
use Encore\Admin\Layout\Content;
use Illuminate\Support\MessageBag;

class DistributeConfigController extends Controller
{
    use ModelForm;
    /**
     * Edit interface.
     *
     * @param $id
     * @return Content
     */
    public function edit($id)
    {

        return Admin::content(function (Content $content) use ($id) {

            $content->header('header');
            $content->description('description');

            $content->body($this->form()->edit($id));
        });
    }
    protected function form()
    {

        return Admin::form(Distribute::class, function (Form $form) {

            $form->currency('first','一级分销推广首购分成比例')->symbol('%');
            $form->currency('first_recharge','一级分销推广复购分成比例')->symbol('%');
            $form->currency('second','二级分销推广首购分成比例')->symbol('%');
            $form->currency('second_recharge','二级分销推广复购分成比例')->symbol('%');
            $form->saved(function ($form) {

                $success = new MessageBag([
                    'title'   => '保存成功',
                    'message' => '保存成功',
                ]);

                return back()->with(compact('success'));
            });

            $form->tools(function (Form\Tools $tools) {

                // 去掉返回按钮
                $tools->disableBackButton();

                // 去掉跳转列表按钮
                $tools->disableListButton();


            });



        });
    }
}
